
$(document).ready(function () {
    get_items();
        });
    
     
    function get_items() {
        $.ajax({
            type: "GET",
            url: SERVER_PATH + "/product/list",
            xhrFields: {withCredentials: true},
            success: function (result) {
                if (result.status) {
                    alertBox(result.data.message);
                    return false;
                }
                set_items(result.data);
            }
        });
    }
    
    
    
    function set_items(items) {
        if (!items) {
            return false;
        }
    
    
    
        $.each(items, function (i, item) {
    
    
                var tr=
                    '<tr class=pros>'
                    +'<td class="prosid">'+'<a href="item.html"> <span style="color:white;position: relative;top:70px;cursor:pointer;" class=editpro>1</span></a>' +'<td>'
    
    
                    +'<td class="prosnm">'+'<span style="position: relative;top:70px;;">电动汽车</span>' +'<td>'
                    +'<td class="prosps">'+'<span style="position: relative;top:70px;">1000</span>' +'<td>'
                    +'<td class="prosint">'+'<span style="position: relative;top:70px;">很好玩</span>' +'<td>'
                    +'<td class="prosam">'+'<span style="position: relative;top:70px;">电动汽车</span>' +'<td>'
                    +'<td class="proscls">'+'<span style="position: relative;top:70px;">电动汽车</span>' +'<td>'
                    +'<td class="prosurl">'+'<span class="pic"><img width="200px" height="150px" src=""/></span>' +'<td>'
    
    
                    +'</tr>';
    
    
                var $prod = $(tr);
            $prod.find(".prosid span").text(item.id);  
            $prod.find(".prosid a").attr("href", "editdel.html?id=" + item.id);
            $prod.find(".prosnm span").text(item.name);
            $prod.find(".prosps span").text(item.price);
            $prod.find(".prosint span").text(item.introduction);
            $prod.find(".prosam span").text(item.proAmount);
            $prod.find(".proscls span").text(item.proClass);
            $prod.find(".pic img").attr("src", item.imageUrl);
    
           
            console.log($prod)
            // 显示内容
            $(".proslist").append($prod);
            
            
        });
    }
    
    